package com.ssy.jt808.gateway.domain.converter;

import com.ssy.jt808.gateway.infrastructure.constant.Jt808Constant;
import com.ssy.jt808.gateway.sdk.terminal.constant.location.addition.AdAlarmEnum;
import com.ssy.jt808.gateway.sdk.terminal.pojo.info.alarm.AdAlarmInfo;
import com.ssy.jt808.gateway.sdk.terminal.pojo.info.alarm.AlarmIdentificationInfo;
import com.ssy.jt808.protocol.commons.transform.attribute.AlarmAD;

/**
 * @author wangzezhou
 */
public class AdAlarmInfoConverter{

  public static AdAlarmInfo convertAdAlarmInfo( AlarmAD alarm ){

    AdAlarmEnum type = AdAlarmEnum.type(alarm.getType());

    AdAlarmInfo alarmInfo = new AdAlarmInfo();
    alarmInfo.setId(alarm.getId());
    alarmInfo.setState(alarm.getState());
    alarmInfo.setType(type);
    alarmInfo.setThresholdTime(alarm.getThresholdTime());
    alarmInfo.setThreshold1(alarm.getThreshold1());
    alarmInfo.setThreshold2(alarm.getThreshold2());
    alarmInfo.setSpeed(alarm.getSpeed());
    alarmInfo.setAltitude(alarm.getAltitude());
    alarmInfo.setLat((float)(alarm.getLatitude()/Jt808Constant.ONE_MILLION));
    alarmInfo.setLng((float)(alarm.getLongitude()/Jt808Constant.ONE_MILLION));
    // 车辆状态
    alarmInfo.setVehicleStateBits(alarm.getStatusBit());
    alarmInfo.setAlarmTime(alarm.getAlarmTime());

    // 报警标识
    AlarmIdentificationInfo alarmIdentificationInfo = new AlarmIdentificationInfo();
    alarmInfo.setAlarmIdentification(alarmIdentificationInfo);
    alarmIdentificationInfo.setDeviceId(alarm.getDeviceId());
    alarmIdentificationInfo.setTime(alarm.getDateTime());
    alarmIdentificationInfo.setSequenceNo(alarm.getSequenceNo());
    alarmIdentificationInfo.setAttachmentNum(alarm.getAttachmentNum());
    return alarmInfo;
  }
}
